package com.kaishengit.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kaishengit.dao.UserDao;
import com.kaishengit.dao.core.Where;
import com.kaishengit.pojo.User;

@Service
@Transactional
public class UserService {

	private UserDao userDao;
	
	public User login(User user) {
		User u = userDao.findByUnique("username", user.getUsername());
		if(u!=null && u.getPassword().equals(user.getPassword())){
			return u;
		} else{
			return null;
		}
	}
	
	
	
	@Autowired
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}


	@Transactional(readOnly=true)
	public List<User> findAll(List<Where> whereList) {
		return userDao.find(whereList) ;
	}
	
}
